/*
 *  ConcreteRegion.cpp
 *  SoundController0002
 *
 *  Created by jiro on 11/10/04.
 *  Copyright 2011 jiro music. All rights reserved.
 *
 */

#include "ConcreteRegion.h"
#include "ConcreteLine.h"

namespace sc
{
namespace system0039
{
	double ConcreteRegion::GetDuration() const
	{
		double maxDuration = 0.0;
		for ( int i = 0, count = size(); i < count; i++ )
		{
			double duration = at( i ).GetDuration();
			if ( maxDuration < duration )
			{
				maxDuration = duration;
			}
		}
		return maxDuration;
	}

	void ConcreteRegion::AddLines( const std::vector< ConcreteLine >& lines )
	{
		for ( int i = 0, count = lines.size(); i < count; i++ )
		{
			std::vector< ConcreteLine >::push_back( lines[ i ] );
		}		}

	void ConcreteRegion::ToSoundElements(
		std::vector< std::vector< std::vector< const ::sc::SoundElement32* > > >& region0,
		std::vector< std::vector< std::vector< const ::sc::SoundElement32* > > >& region1 ) const
	{
		for ( int i = 0, count = size(); i < count; i++ )
		{
			const ConcreteLine& line = at( i );
			std::vector< std::vector< const ::sc::SoundElement32* > > lines[ 2 ];
			line.ToSoundElements( lines[ 0 ], lines[ 1 ] );
			region0.push_back( lines[ 0 ] );
			region1.push_back( lines[ 1 ] );
//			std::cout << lines[ 0 ].at( 0 ).at( 0 )->ToString() << std::endl;
//			std::cout << lines[ 1 ].at( 0 ).at( 0 )->ToString() << std::endl;
		}
	}

	std::string ConcreteRegion::ToString( int tabCount ) const
	{
		std::stringstream ss;
		for ( int i = 0; i < tabCount; i++ )
		{
			ss << "\t";
		}
		ss << "ConcreteRegion:\n";
		for ( int i = 0, count = size(); i < count; i++ )
		{
			ss << at( i ).ToString() << "\n";
		}
		return ss.str();
	}
}
}
